<?php

namespace app\admin\service\statistics\traits;

use app\admin\service\statistics\filters\TimeFilter;

/**
 * Trait FilterCreatedTrait
 * @package app\admin\service\statistics\traits
 */
trait FilterCreatedTrait
{

    /**
     * 实现时间筛选
     * @param \think\db\Query $query
     * @param TimeFilter $filter
     * @return void
     */
    protected function filterByTimeFilter($query, TimeFilter $filter): void
    {

        $startTime = $filter->getStartTime();
        $endTime = $filter->getEndTime();

        $query->timeRange($startTime, $endTime, 'created', 'created');
    }
}